package com.cnap.multiclouldmgmt.service;

import com.cnap.multiclouldmgmt.model.dockerHarborModel.DestRegistryModel;
import com.cnap.multiclouldmgmt.model.dockerHarborModel.HarborPolicyModel;
import com.cnap.multiclouldmgmt.model.dockerHarborModel.PolicyModel;
import com.cnap.multiclouldmgmt.model.dockerHarborModel.ProjectInfoModel;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
 * @author dyq
 * 基础服务
 */
public interface DockerHarborService {

    /**
     * 新建一个集群管理的时候，
     * 在中心测的仓库上面，
     * 建立一个和这个集群本地仓库同步的规则
     * @param k8sClusterIp
     * @param userName
     * @throws IOException
     */
    void createClusterHarborCopyRule(String k8sClusterIp,String userName) throws IOException;

    /**
     * 注册一个仓库
     * @param k8sClusterIp
     * @throws UnsupportedEncodingException
     */
    void registerRemoteHarbor(String k8sClusterIp) throws UnsupportedEncodingException;

    /**
     * 获取所有已经注册的仓库
     * @return
     */
    List<DestRegistryModel> getAllRegisterHarbor(String k8sClusterIp);

    /**
     * 增加同步规则，默认就是按事件驱动
     * @param k8sClusterIp
     * @param destRegistryModel
     * @param projectName
     * @throws UnsupportedEncodingException
     */
    void addPolicy(String k8sClusterIp,DestRegistryModel destRegistryModel,String projectName) throws UnsupportedEncodingException;

    /**
     *
     * @param k8sClusterIp
     * @param projectName
     * @throws UnsupportedEncodingException
     */
    void addHarborProject(String k8sClusterIp,String projectName) throws UnsupportedEncodingException;

    /**
     *
     * @param k8sClusterIp
     * @return
     */
    List<ProjectInfoModel> getAllHarborProject(String k8sClusterIp);

    /**
     *
     * @param k8sClusterIp
     * @param destRegistryModel
     * @param projectName
     */
    void syncExistImages(String k8sClusterIp, DestRegistryModel destRegistryModel,String projectName) throws UnsupportedEncodingException;

    /**
     * 删除一个project下所有的镜像
     * @param k8sClusterIp
     */
    void delProjectImages(String k8sClusterIp) throws Exception;

    /**
     * 镜像拷贝
     * @param id
     * @throws UnsupportedEncodingException
     */
    void doImageCopy(String k8sClusterIp,String id) throws UnsupportedEncodingException;

    /**
     * 获取所有策略
     * @return
     */
    List<PolicyModel> getAllPolicies(String dockerUrl,String k8sClusterIp);

    /**
     * 删除集群之后删除同步策略
     * @param k8sClusterIp
     */
    void delHarborPolicy(String k8sClusterIp);

    /**
     * 删除集群上指定的镜像
     * @param clusterName
     * @param imageInfo
     */
    void delClusterImage(String clusterName,String imageInfo);
}
